﻿<Window x:Class="advadev.Windows.DragDrop.Demo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:advadevDragDrop="clr-namespace:advadev.Windows.DragDrop;assembly=advadev.Windows.DragDrop"
        xmlns:local="clr-namespace:advadev.Windows.DragDrop.Demo"
        Title="Drag-Drop Demo with Touch Support" Height="640" Width="1024" Background="#CCCCCC">

    <advadevDragDrop:DragDropContainer Margin="10" ClipToBounds="True">
        <Grid Background="#FFFFFF">
            <Grid.Resources>
                <ControlTemplate x:Key="DragItemControlTemplate" TargetType="{x:Type ContentControl}">
                    <Border Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="5" Cursor="Hand" Height="40" Width="160">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="50" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="Drag Me!" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Center" />
                            <TextBlock Grid.Column="1" Text="{Binding Counter}" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="advadevDragDrop:DragDropContainer.IsDragged" Value="False" />
                                <Condition Property="advadevDragDrop:DragDropContainer.IsDragActive" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="border" Property="BorderBrush" Value="Orange" />
                            <Setter TargetName="border" Property="BorderThickness" Value="2" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="advadevDragDrop:DragDropContainer.IsDragged" Value="False" />
                                <Condition Property="advadevDragDrop:DragDropContainer.IsActiveDropTarget" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="border" Property="BorderBrush" Value="YellowGreen" />
                            <Setter TargetName="border" Property="BorderThickness" Value="2" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
                <ControlTemplate x:Key="DropItemControlTemplate" TargetType="{x:Type ContentControl}">
                    <Border Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="25" Height="50" Width="50">
                        <Grid>
                            <TextBlock Grid.Column="1" Text="{Binding Counter}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="advadevDragDrop:DragDropContainer.IsDragActive" Value="True">
                            <Setter TargetName="border" Property="BorderBrush" Value="Orange" />
                            <Setter TargetName="border" Property="BorderThickness" Value="2" />
                        </Trigger>
                        <Trigger Property="advadevDragDrop:DragDropContainer.IsActiveDropTarget" Value="True">
                            <Setter TargetName="border" Property="BorderBrush" Value="YellowGreen" />
                            <Setter TargetName="border" Property="BorderThickness" Value="2" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Border Grid.Column="0" Grid.Row="0" Background="#FFFFFF" BorderBrush="#AAAAAA" BorderThickness="1" Margin="10">
                <Grid>
                    <TextBlock Text="Drag one of these elements and drop it above one of the circles on the right. The number in the drag-element will decrease, the number in the drop-element will increase. If the number of a drag-element is 0 it can not be dragged any more" TextWrapping="Wrap" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    <TextBlock Text="You can use the mouse for dragging or do this by touch" FontWeight="Bold" Foreground="Blue" TextWrapping="Wrap" Margin="10,60,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    <ContentControl DataContext="{Binding DragItem1}" Background="LightBlue" BorderBrush="Blue" Template="{StaticResource DragItemControlTemplate}" Margin="250,100,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup1"
                                    advadevDragDrop:DragDropContainer.IsDraggable="True"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="False"
                                    advadevDragDrop:DragDropContainer.SourceDropCommand="{Binding Source={x:Static local:DragDropCommands.DecreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.SourceDropCommandParameter="{Binding}" />
                    <ContentControl DataContext="{Binding DragItem2}" Background="LightBlue" BorderBrush="Blue" Template="{StaticResource DragItemControlTemplate}" Margin="50,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup1"
                                    advadevDragDrop:DragDropContainer.IsDraggable="True"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="False"
                                    advadevDragDrop:DragDropContainer.SourceDropCommand="{Binding Source={x:Static local:DragDropCommands.DecreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.SourceDropCommandParameter="{Binding}" />
                </Grid>
            </Border>
            <Border Grid.Column="1" Grid.Row="0" Background="#FFFFFF" BorderBrush="#AAAAAA" BorderThickness="1" Margin="10">
                <Grid>
                    <TextBlock Text="If you drag one element on the left side a orange border indicates whether a circle is a valid drop target. If the drag-element if above a circle its border color will change to green. If the number in a circle is 15 it is not longer a valid drop target" TextWrapping="Wrap" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    <ContentControl DataContext="{Binding DropItem1}" Background="Beige" BorderBrush="Black" Template="{StaticResource DropItemControlTemplate}" Margin="250,100,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup1"
                                    advadevDragDrop:DragDropContainer.IsDraggable="False"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                    <ContentControl DataContext="{Binding DropItem2}" Background="Beige" BorderBrush="Black" Template="{StaticResource DropItemControlTemplate}" Margin="50,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup1"
                                    advadevDragDrop:DragDropContainer.IsDraggable="False"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                    <ContentControl DataContext="{Binding DropItem3}" Background="Beige" BorderBrush="Black" Template="{StaticResource DropItemControlTemplate}" Margin="300,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup1"
                                    advadevDragDrop:DragDropContainer.IsDraggable="False"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                </Grid>
            </Border>
            <Border Grid.Column="0" Grid.Row="1" Background="#FFFFFF" BorderBrush="#AAAAAA" BorderThickness="1" Margin="10">
                <Grid>
                    <TextBlock Text="Same as above. But each drag-element is also a possible drop-element" TextWrapping="Wrap" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    <ContentControl DataContext="{Binding DragItem3}" Background="LightGray" BorderBrush="Gray" Template="{StaticResource DragItemControlTemplate}" Margin="250,100,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup2"
                                    advadevDragDrop:DragDropContainer.IsDraggable="True"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.SourceDropCommand="{Binding Source={x:Static local:DragDropCommands.DecreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.SourceDropCommandParameter="{Binding}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                    <ContentControl DataContext="{Binding DragItem4}" Background="LightGray" BorderBrush="Gray" Template="{StaticResource DragItemControlTemplate}" Margin="50,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup2"
                                    advadevDragDrop:DragDropContainer.IsDraggable="True"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.SourceDropCommand="{Binding Source={x:Static local:DragDropCommands.DecreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.SourceDropCommandParameter="{Binding}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                </Grid>
            </Border>
            <Border Grid.Column="1" Grid.Row="1" Background="#FFFFFF" BorderBrush="#AAAAAA" BorderThickness="1" Margin="10">
                <Grid>
                    <TextBlock Text="Same as above" TextWrapping="Wrap" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    <ContentControl DataContext="{Binding DropItem4}" Background="Cyan" BorderBrush="Black" Template="{StaticResource DropItemControlTemplate}" Margin="250,100,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup2"
                                    advadevDragDrop:DragDropContainer.IsDraggable="False"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                    <ContentControl DataContext="{Binding DropItem5}" Background="Cyan" BorderBrush="Black" Template="{StaticResource DropItemControlTemplate}" Margin="50,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup2"
                                    advadevDragDrop:DragDropContainer.IsDraggable="False"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                    <ContentControl DataContext="{Binding DropItem6}" Background="Cyan" BorderBrush="Black" Template="{StaticResource DropItemControlTemplate}" Margin="300,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                    advadevDragDrop:DragDropContainer.DragDropGroupName="dragDropGroup2"
                                    advadevDragDrop:DragDropContainer.IsDraggable="False"
                                    advadevDragDrop:DragDropContainer.IsDropTarget="True"
                                    advadevDragDrop:DragDropContainer.TargetDropCommand="{Binding Source={x:Static local:DragDropCommands.IncreaseCounterCommand}}"
                                    advadevDragDrop:DragDropContainer.TargetDropCommandParameter="{Binding}" />
                </Grid>
            </Border>
        </Grid>
    </advadevDragDrop:DragDropContainer>

</Window>
